package com.yzr.common.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.CellExtra;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * @description
 * @author: yx-0173
 * @date: 2021-07-22 18:04
 **/
@Slf4j
public class DeviceListener extends AnalysisEventListener<DeviceListener.EntityClass> {
    public DeviceListener() {
        super();
    }

    @Override
    public void invoke(EntityClass entityClass, AnalysisContext analysisContext) {
        // 解析一条数据后
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        // 解析完数据之后要做的
    }


    @Override
    public void invokeHead(Map<Integer, CellData> headMap, AnalysisContext context) {
        super.invokeHead(headMap, context);
    }

    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        super.invokeHeadMap(headMap, context);
    }

    @Override
    public void extra(CellExtra extra, AnalysisContext context) {
        super.extra(extra, context);
    }

    @Override
    public void onException(Exception exception, AnalysisContext context) throws Exception {
        // 异常
        super.onException(exception, context);
    }

    @Override
    public boolean hasNext(AnalysisContext context) {
        return super.hasNext(context);
    }

    @Data
    public static class EntityClass {

        private String name;

        private Integer age;
    }
}
